
package Package1;


import javax.swing.ImageIcon;
import javax.swing.JLabel;

import myui.component.unit.DesginerImage;

public  class Fork extends JLabel{

    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int list = 0;
    
    public Fork(){
        super();
        setIcon(DesginerImage.FORK);
        updateUI();
    }   
   
    public synchronized void p(Thread parent) {
		list++;
		if(list>1){
			try {
				parent.setPriority(list-1);
				wait();
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		setIcon(null);
        updateUI();

    }	

    public synchronized void v(Thread parent) {
		list--;
		if(list>=1){
			notify();
		}
		setIcon(DesginerImage.FORK);	
        updateUI();

		parent.setPriority(Thread.NORM_PRIORITY);
    }	


 }